package org.client.nosql.redis;


import org.pocs.json.gson.GsonUtil;

import redis.clients.jedis.Jedis;

public class RedisUtil<T> {

	Jedis jedis = null;
	public static String KEY_STORE = "keys";
	
	public RedisUtil() {
		jedis = new Jedis("localhost", 6379);	
	}
	
	public static void main(String[] args) {
		Jedis jedis = new Jedis("localhost", 6379);
		
for (int i = 0; i < 5; i++) {
	//		jedis.set("foo", "bar");
	jedis.append("foo", "bar1");
	//jedis.eval("RPUSH mylist 'hello'");
	//jedis.eval("RPUSH mylist 'hell1o'");
	String value = jedis.get("foo");
	System.out.println(value);
}
jedis.persist("foo");
		
	}
	
	public void add(String key, T obj) {
		
		String value = new GsonUtil<T>().fromObjectToJson(obj);
		
		jedis.rpush(key, value);
		jedis.zadd(KEY_STORE, Double.parseDouble(key), key);
	}
	
	public void displayAll() {
	//	jedis.
	}
	
	public void displaySorted() {
		
	}
	
	
}
